package dnl.confij;

/**
 * Converts a value from and to <code>String</code>. Those strings should be
 * string that appear is configurations, thus, this is completely different than
 * <code>toString()</code>. For example, a string that describe a color looks
 * something like 34,101,88.
 * 
 * @author Daniel Or
 * 
 */
public interface ValueConverter {

	/**
	 * Formats the given object into a <code>String</code> that is
	 * configuration 'friendly' (that is, convenient to read).
	 * 
	 * @param obj
	 *            an <code>Object</code> to format.
	 * @return a <code>String</code>ed representation of the object, that
	 *         will be used to store it in <code>Configuration</code>s.
	 */
	public String format(Object obj);

	/**
	 * Converts a <code>String</code>ed representation of the object back
	 * into an <code>Object</code>.
	 * 
	 * @param s
	 *            a configuration string that may be converted back into an
	 *            <code>Object</code>.
	 * @return an <code>Object</code> that corresponds to the given string.
	 */
	public Object parse(String s);

	/**
	 * The types that are supported by this conversion.
	 * 
	 * @return the <code>Class</code>es that this converter knows to work
	 *         with.
	 */
	public Class<?>[] getSupportedTypes();
}
